package com.fxm.controller;

import com.fxm.returns.RespEntity;
import com.fxm.service.QuestionService;
import com.fxm.vo.param.OpenParam;
import com.fxm.vo.param.QuestionParam;
import com.fxm.vo.result.QuestionResult;
import com.fxm.vo.result.RuleResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * <p>
 * 答题 前端控制器
 * </p>
 *
 * @author fxm
 * @since 2021-01-07
 */
@RestController
@RequestMapping("/question")
@Slf4j
@Api(value = "今日答题接口", tags = "今日答题接口")
public class QuestionController {

    @Resource
    private QuestionService questionService;

    @PostMapping("/integral")
    @ApiOperation("可获积分")
    public RespEntity<Integer> getAllIntegral() {
        RespEntity<Integer> respEntity = questionService.getAllIntegral();
        return respEntity;
    }

    @PostMapping("/rule")
    @ApiOperation(value = "答题规则")
    public RespEntity<RuleResult> getQuestionRule() {
        RespEntity<RuleResult> respEntity = questionService.getQuestionRule();
        return respEntity;
    }

    @PostMapping("/init")
    @ApiOperation(value = "题目初始化")
    public RespEntity<QuestionResult> getQuestionInit() {
        RespEntity<QuestionResult> respEntity = questionService.getQuestionInit();
        return respEntity;
    }

    @PostMapping("/next")
    @ApiOperation(value = "下一题")
    public RespEntity<QuestionResult> nextQuestion(@RequestBody QuestionParam questionParam) {
        RespEntity<QuestionResult> respEntity = questionService.getNextQuestion(questionParam);
        return respEntity;
    }

    @PostMapping("/challenge")
    @ApiOperation(value = "剩余挑战次数")
    public RespEntity<Integer> getChallengeNumbers(@RequestBody OpenParam openParam) {
        RespEntity<Integer> respEntity = questionService.getChallengeNumbers(openParam);
        return respEntity;
    }

    @PostMapping("/update")
    @ApiOperation(value = "挑战次数变更")
    public RespEntity updateChallengeNum(@RequestBody OpenParam openParam) {
        RespEntity respEntity = questionService.updateChallengeNum(openParam);
        return respEntity;
    }

}
